function f(x, y) {
    return x + y ** 2
}

var z = f(1, 2)
var k = f(2, 5)
    // console.log(z)
    // console.log(k)

// var str1 = "干啥咧！"

// function f1() {
//     var str = "哈哈";
//     console.log(str1)
//     return 1
// }

// var res = f1();
// console.log(str)
// var num = 2;
// var array1 = [1, [2, 3], 2, 3, 4]

function lan(l) {
    l = typeof l == "undefined" ? "汉语" : l
    console.log(`你的的系统语言是${l}`)
}


function mySlice(str, start, end) {
    end = end == undefined ? str.length : end;
    // start = start == undefined ? 0 : start;
    if (start == undefined) {
        start = 0
    } else {
        start = start
    }
    var res = '';
    for (var i = start; i < end; i++) {
        res += str[i]
    };
    return res
}
var str1 = "abcdefg";
var str2 = mySlice(str1, 2, 3);
// console.log(str2)
var x = 2;

function inc() {
    n = x
    n = n + 1;
    return n
}
var x = 2;
var res = inc(2);
// console.log(`程序运算结果${res}`);
// console.log(`x的值${x}`);
var a1 = [1, 2, 3, [2, 3], 4];

function add2(n) {
    n[3][0] += "改变"
    console.log(n)
}
// add2(a1);
// console.log(a1)
function print(n) {
    n = n || "hello";
    console.log(n)
}

function print1(n) {
    n = n == undefined ? "哈哈" : n;
    console.log(n)
}
// print(0)
// print1(0)

function stuInfo(stu) {
    console.log(`
        姓名：${stu.name}
        年龄：${stu.age}
        专业：${stu.major}
        籍贯：${stu.origin};
    `);
}
//对象不区分顺序
var yh = { name: "杨浩", origin: "北京人", age: 20, major: "挖掘机" };
// stuInfo(yh)
function sum1(a, b, c, d) {

    var res = a + b + c,
        d;
    // console.log(res)
    // console.log(arguments)
    // console.log(arguments[4])
    console.log('你总共输入了' + arguments.length + '个参数，分别为：')
        // for (var i = 0; i < arguments.length; i++) {
        //     console.log(arguments[i])
        // }
    for (idx in arguments) {
        console.log(arguments[idx])
    }
    return res

}
sum(1, 2, 3, 4, 5, 20);
sum(1, 2)
sum(20, 40, 50)

function sum() {
    var res = 0;
    for (arg of arguments) {
        res += arg
    };
    return res
}
// var x = sum(1, 2, 3, 4, 5, 20);
// var x1 = sum(1, 2);
// var x2 = sum(20, 40, 50);
// console.log(x);
// console.log(x1);
// console.log(x2);